package com.dhcc.DRGsHosp.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.openkoala.koala.commons.InvokeResult;
import org.openkoala.security.shiro.CurrentUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dhcc.DRGsHosp.facade.DifficultGroupMonitorFacade;
import com.dhcc.DRGsHosp.facade.KeyDisGroupFacade;

@Controller()
@RequestMapping("DifficultGroup")
public class DifficultGroupMonitorControler {

	@Autowired
	private DifficultGroupMonitorFacade difficultGroupMonitorFacade;
	
	@Autowired
    private KeyDisGroupFacade keyDisGroupFacade;
	/**
	 * 
	 *  getTotalCountDiffi.  
	 *  @Description：疑难病组组数
	 *  @Author ZouYiyu
	 *  @param dateFrom
	 *  @param dateTo
	 *  @param defalutType
	 *  @return 
	 *  @Date:2017年12月7日下午2:37:23
	 */
	@ResponseBody
	@RequestMapping(value="/getTotalCountDiffi")
	public  List<Map<String, Object>> getTotalCountDiffi(String dateFrom,String dateTo,String defalutType,String hospCode){
        String account=CurrentUser.getUserAccount();
        String roleName=CurrentUser.getRoleName();
		return difficultGroupMonitorFacade.getTotalCountDiffi(dateFrom,dateTo,defalutType,roleName,account,hospCode);
		
	}  
	
	/**
	/**
	 * 
	 *  getDiffiGroupMdc.  
	 *  @Description：院内疑难病组按MDC分布
	 *  @Author ZouYiyu
	 *  @param yearCode
	 *  @return 
	 *  @Date:2017年12月5日下午2:37:02
	 */
	@ResponseBody
	@RequestMapping(value="/getDiffiGroupMdc")
	public List<Map<String,Object>>getDiffiGroupMdc(String yearCode,String hospCode){
        String account=CurrentUser.getUserAccount();
        String roleName=CurrentUser.getRoleName();
		return difficultGroupMonitorFacade.getDiffiGroupMdc(yearCode,roleName,account,hospCode);
	}
	/**
	 * 
	 *  getDiffiGroupDrg.  
	 *  @Description：院内疑难病组按MDC下DRG分布
	 *  @Author ZouYiyu
	 *  @param yearCode
	 *  @return 
	 *  @Date:2017年12月5日下午4:05:17
	 */
	@ResponseBody
	@RequestMapping(value="/getDiffiGroupDrg")
	public List<Map<String,Object>>getDiffiGroupDrg(String yearCode,String mdcCode,String hospCode){
        String account=CurrentUser.getUserAccount();
        String roleName=CurrentUser.getRoleName();
		return difficultGroupMonitorFacade.getDiffiGroupDrg(yearCode,mdcCode,roleName,account,hospCode);
	}
	/**
	 * 
	 *  delDiffiGroup.  
	 *  @Description：删除疑难病组
	 *  @Author ZouYiyu
	 *  @param drgCode
	 *  @return 
	 *  @Date:2017年12月6日上午9:14:31
	 */
	@ResponseBody
	@RequestMapping(value="/delDiffiGroup")
	public InvokeResult delDiffiGroup(String drgCode,String hospCode){
        String account=CurrentUser.getUserAccount();
        String roleName=CurrentUser.getRoleName();
		difficultGroupMonitorFacade.delDiffiGroup(drgCode,roleName,account,hospCode);
		return InvokeResult.success();
	}
	/**
	 * 
	 *  getExtraDiffiGroup.  
	 *  @Description：获取疑难病组以外的病组 让用户筛选
	 *  @Author ZouYiyu
	 *  @param yearCode
	 *  @return 
	 *  @Date:2017年12月6日上午10:03:11
	 */
	@ResponseBody
	@RequestMapping(value="/getExtraDiffiGroup")
	public InvokeResult getExtraDiffiGroup(String yearCode,String hospCode){
        String account=CurrentUser.getUserAccount();
        String roleName=CurrentUser.getRoleName();
		return InvokeResult.success(difficultGroupMonitorFacade.getExtraDiffiGroup(yearCode,roleName,account,hospCode));
	}
	/**
	 * 
	 *  addDiffiGroup.  
	 *  @Description：添加疑难病组
	 *  @Author ZouYiyu
	 *  @param drgCode
	 *  @return 
	 *  @Date:2017年12月7日下午1:03:04
	 */
	@ResponseBody
	@RequestMapping(value="/addDiffiGroup")
	public InvokeResult addDiffiGroup(String drgCode,String hospCode){
        String account=CurrentUser.getUserAccount();
		difficultGroupMonitorFacade.addDiffiGroup(drgCode,account,hospCode);
		return InvokeResult.success();
	}
	/**
	 * 
	 *  setDiffiGroup.  
	 *  @Description：设置疑难病组
	 *  @Author ZouYiyu
	 *  @param yearCode
	 *  @param caseCntPer
	 *  @param mdcWeightPer
	 *  @return 
	 *  @Date:2017年12月7日下午3:02:30
	 */
	@ResponseBody
	@RequestMapping(value="/setDiffiGroup")
	public InvokeResult setDiffiGroup(String yearCode,int caseCntPer,int mdcWeightPer,String hospCode){
        String account=CurrentUser.getUserAccount();
		return InvokeResult.success(difficultGroupMonitorFacade.setDiffiGroup(yearCode, caseCntPer,mdcWeightPer,account,hospCode));
	}
	
	/**
	 * 
	 * @Title: getKeyFilterInit
	 * @author:LiQingYang   
	 * @Description: 获取疑难病组初始化筛选条件
	 * @param: @param code
	 * @param: @return      
	 * @return: InvokeResult      
	 * @throws
	 * @date:2017年12月13日 上午11:42:31
	 */
    @ResponseBody
    @RequestMapping("/getKeyFilterInit")
    public InvokeResult getKeyFilterInit(String hospCode){
        Map<String,Object> initMap = new HashMap<String,Object>();
        String account=CurrentUser.getUserAccount();
        initMap.put("years",keyDisGroupFacade.getCaseYears(hospCode));
        String cfgCode = "DiffiConfig"+"-"+account+"-"+hospCode;
        initMap.put("cfg",keyDisGroupFacade.findSizerCondition(cfgCode));
        return InvokeResult.success(initMap);
    }
}
